# -*- coding: utf-8 -*-
# @Author : Yuan
from apps.goods.models import SKU
from apps.orders.models import OrderInfo, OrderGoods
from rest_framework import serializers


class SKUModelSerializer(serializers.ModelSerializer):

    class Meta:
        model = SKU
        fields = ['name', 'default_image']


class OrderGoodsModelSerializer(serializers.ModelSerializer):
    sku = SKUModelSerializer()

    class Meta:
        model = OrderGoods
        fields = '__all__'


class OrderInfoModelSerializer(serializers.ModelSerializer):
    skus = OrderGoodsModelSerializer(many=True)

    class Meta:
        model = OrderInfo
        fields = '__all__'


class UpdateOrderInfoModelSerializer(serializers.ModelSerializer):

    class Meta:
        model = OrderInfo
        fields = ['order_id', 'status']
        extra_kwargs = {
            'order_id': {'read_only': True}
        }






